home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
F1 Licenseware
/
F1 Licenseware - Volume 1.iso
/
disks
/
050a.dms
/
050a.adf
/
ASCII_READER.AMOS
/
ASCII_READER.amosSourceCode
next >
Wrap
AMOS Source Code
|
1992-02-26
|
5KB
|
223 lines
'*****************************************************************************
'* Text File Dumper Routine V1 *
'* Originally Written By Steve Bennett *
'* Adapted for Absolute beginners guide to Amos *
'*****************************************************************************
_SETUP_MENU
Screen Open 1,658,167,2,Hires : Screen Display 1,,103,,
Curs Off : Flash Off : Colour 0,$0 : Colour 1,$FFF
Cls 0 : Pen 1 : Paper 0 : Locate 0,1
Screen To Front 0
Global SH
SH=1
_BANKLOAD
Rem this is the main loop, checks for option selection then calls
Rem relevant procedure.
'------------------------
Do
Screen 0
MZ=Mouse Zone : MK=Mouse Key
If MZ=1 and MK=1 Then _BANKLOAD
If MZ=2 and MK=1 Then _NLINE
If MZ=3 and MK=1 Then _NPAGE
If MZ=4 and MK=1 Then _DUMP_FILE
If MZ=5 and MK=1 Then Edit
Loop
Procedure _NLINE
'shared means the following variables will be SHARED with the other procedures
'------------------------------------------------------------------------------
Shared BEGIN,POSITION,FINISH,CURRENT_LINE
If Length(9)=0 Then Bell 1 : Pop Proc
If POSITION=FINISH Then POSITION=0 : CURRENT_LINE=0 : _NPAGE
Screen 1
TEMP$=""
While Asc(TMP$)<>10 and POSITION<>FINISH
LETTER=Peek(BEGIN+POSITION)
TMP$=Chr$(LETTER)
If Asc(TMP$)=10
Print
Screen 0 : Inc CURRENT_LINE : Ink 1,12 : Text 470,51," " : Text 470,51,Str$(CURRENT_LINE) : Screen 1
Else
TEMP$=TEMP$+TMP$
End If
If POSITION<>FINISH Then Inc POSITION
Wend
Print TEMP$;
End Proc
Procedure _NPAGE
Shared BEGIN,POSITION,FINISH,CURRENT_LINE
Repeat : Until Mouse Key=0
If Length(9)=0 Then Bell 1 : Pop Proc
If POSITION=FINISH Then POSITION=0 : CURRENT_LINE=0
Screen 1
Cls 0 : Home
TEMP$=""
While Y Curs<>19 and POSITION<>FINISH
LETTER=Peek(BEGIN+POSITION)
TMP$=Chr$(LETTER)
If Asc(TMP$)=10
Print
Inc CURRENT_LINE
Print TEMP$; : TEMP$=""
Else
TEMP$=TEMP$+TMP$
End If
If POSITION<>FINISH Then Inc POSITION
Wend
Screen 0 : Ink 1,12 : Text 470,51," " : Text 470,51,Str$(CURRENT_LINE) : Screen 1
End Proc
Procedure _SETUP_MENU
Unpack 15 To 0
Reserve Zone 8
For Z=1 To 8
Read A,B,C,D
Set Zone Z,A,B To C,D
Next Z
Data 112,22,190,36
Data 198,22,276,36
Data 282,22,360,36
Data 366,22,444,36
Data 450,22,530,36
Data 284,77,364,91
Data 370,77,448,91
Data 454,77,536,91
End Proc
Procedure _DUMP_FILE
Repeat : Until Mouse Key=0
If Length(9)=0 Then Bell 1 : Pop Proc
Ink 1,12
Text 130,69,"Please Ensure That The Printer Is Ready To Print"
Screen Display 0,,,,97
Repeat : Until Mouse Zone>5 and Mouse Key=1
If Mouse Zone=6 Then SET=-1
If Mouse Zone=8 Then Screen Display 0,,,,60 : Pop Proc
Text 130,69," "
Text 230,69,"Printing Text File"
For T=Start(9) To Start(9)+Length(9)-1
LETTER=Peek(T)
TMP$=Chr$(LETTER)
B=Peek(T-1) : B$=Chr$(B) : B=Asc(B$)
If Asc(TMP$)=9 or Asc(TMP$)=10
If B<>10
Lprint
End If
Else
Lprint TMP$;
End If
Next T
Text 135,69," "
Text 230,69,"Printing Complete"
Wait 100
Screen Display 0,,,,60
End Proc
Procedure _BANKLOAD
Shared BEGIN,FINISH,POSITION,CURRENT_LINE
Screen Hide 0 : Screen Hide 1
Clear Key
Dir$="df0:texts/"
If SH=1 Then NAME$="df0:texts/0_help.txt" : SH=0 : Goto HC
NAME$=Fsel$("*.*","","Select .TXT Text File To Load !","")
If NAME$<>""
HC:
Open In 1,NAME$
L=Lof(1)
Close 1
Erase 9
Reserve As Work 9,L
Bload NAME$,9
BEGIN=Start(9)
FINISH=Length(9)
POSITION=0
CURRENT_LINE=0
Screen Show 0 : Screen Show 1
_FIND_FILE_LENGTH
_NPAGE
End If
Screen Show 0 : Screen Show 1
End Proc
Procedure _FIND_FILE_LENGTH
NUMBER_OF_LINES=0
Screen 0
Ink 1,12
Text 298,51," "
Text 470,51," "
Screen 1 : Cls 0 : Locate 0,1 : Centre "Counting Total Number Of Lines In File"
For T=Start(9) To Start(9)+Length(9)
P=Peek(T)
A$=Chr$(P)
If Asc(A$)=10 Then Inc NUMBER_OF_LINES
Next T
Screen 0
Ink 1,12
Text 298,51," "
Text 298,51,Str$(NUMBER_OF_LINES)
End Proc